package mn.idax.exchange.otc.mapper;

import mn.idax.exchange.otc.domain.AdMarketPrice;
import mn.idax.exchange.otc.domain.FrozenUserAdDTO;
import mn.idax.exchange.otc.domain.RecommendAdsRequest;
import mn.idax.exchange.otc.entity.OTCAds;
import mn.idax.exchange.otc.entity.OTCAdsExample;
import mn.idax.exchange.otc.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface OTCAdsMapper {
    int countByExample(OTCAdsExample example);

    int deleteByExample(OTCAdsExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(OTCAds record);

    int insertSelective(OTCAds record);

    List<OTCAds> selectByExampleWithBLOBsWithRowbounds(OTCAdsExample example, RowBounds rowBounds);

    List<OTCAds> selectByExampleWithBLOBs(OTCAdsExample example);

    List<OTCAds> selectByExampleWithRowbounds(OTCAdsExample example, RowBounds rowBounds);

    List<OTCAds> selectByExample(OTCAdsExample example);

    OTCAds selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") OTCAds record, @Param("example") OTCAdsExample example);

    int updateByExampleWithBLOBs(@Param("record") OTCAds record, @Param("example") OTCAdsExample example);

    int updateByExample(@Param("record") OTCAds record, @Param("example") OTCAdsExample example);

    int updateByPrimaryKeySelective(OTCAds record);

    int updateByPrimaryKeyWithBLOBs(OTCAds record);

    int updateByPrimaryKey(OTCAds record);

    //fengexian
    
    int updateOTCAds(OTCAds record);
    
    int updateOTCAdsStateById(OTCAds record);
    
    int expireBatchOTCAdsState(Map<String, Object> map);
    
    AccountDTO selectAvailableAmountByUserIdAndCoinId(AccountDTO accountDTO);
    
    /**
     * 广告分页list
     * @param
     * @return
     */
    List<ADPageListDTO> getADList(OTCAdPageDTO otcAdPageDTO);
    
    /**
     * 分页total
     * @param otcAdPageDTO
     * @return
     */
    Integer getADTotal(OTCAdPageDTO otcAdPageDTO);
    
    /**
     * 我的广告分页list
     * @param otcMyAdPageDTO
     * @return
     */
    List<ADPageListDTO>  getMyADList(OTCMyAdPageDTO otcMyAdPageDTO);
    
    /**
     * 我的广告分页total
     * @param
     * @return
     */
    Integer getMyADTotal(OTCMyAdPageDTO otcMyAdPageDTO);
    
    BigDecimal getMaxPrice(String pairname);
    
    BigDecimal getMinPrice(String pairname);
    
    /**
     * 出售广告  当币种余额低于平台最低限额时  需要更新下架
     * @param otcAutoDownAdDTO
     * @return
     */
    List<OTCAds> getAvailableAmountLessThanLimtList(OTCAutoDownAdDTO otcAutoDownAdDTO);
    
    /**
     * 下架广告
     * @param otcAutoDownAdDTO
     * @return
     */
    int updateStateOTCAdsById(OTCAutoDownAdDTO otcAutoDownAdDTO);
    
    /**
     * 查询过期的广告
     * @param map
     * @return
     */
    List<OTCAds> getExpireBatchOTCAdsState(Map<String, Object> map);
    
    int updateTradeNumberById(OTCAdUpdateTradeNumDTO otcAdUpdateTradeNumDTO);
    
    /**
     * 广告主发布的广告分页list
     * @param otcAdvertiserDTO
     * @return
     */
    List<ADPageListDTO> getOtherUserADList(OTCAdvertiserDTO otcAdvertiserDTO);
    /**
     * 广告主发布的广告分页total
     * @param otcAdvertiserDTO
     * @return
     */
    Integer getOtherUserADTotal(OTCAdvertiserDTO otcAdvertiserDTO);

    ADRecommendListDTO getPraiseRecommendAd(RecommendAdsRequest request);

    List<ADRecommendListDTO> getBuyAvailableAd(RecommendAdsRequest request);

    List<ADRecommendListDTO> getSellAvailableAd(RecommendAdsRequest request);

    //v2广告 查询list
    List<ADRecommendListDTO> getADPageSec(OTCAdPageSecDTO otcAdPageDTO);

    //v2广告 查询total
    Integer getADPageTotalSec(OTCAdPageSecDTO otcAdPageDTO);

    List<OTCAds> getMarketMaxPrice(AdMarketPrice adMarketPrice);

    List<OTCAds> getMarketMinPrice(AdMarketPrice adMarketPrice);

    /**
     * 获取用户在场内被冻结，却在场外发布的广告
     * @return
     */
    List<FrozenUserAdDTO> getFrozenUserPublishAds();

    ADRecommendListDTO getAdDetailInfo(@Param("adId") Integer adId);

    /**
     * 获取所有发布上架广告的用户id
     * @return
     */
    List<Integer> getAllUpAdPublisherId();

    Integer getCountOfUserUpAd(@Param("publisherId")Integer userId);
}